package com.itheima.job.result;

import com.itheima.job.result.enums.ResultEnum;

import java.io.Serializable;

/**
 * @author byZhao
 * @motto Talk is cheap . Show me the code!
 * @modify 2021-11-27 10:50
 * @description  通用的响应对象
 */
public class Result  implements Serializable {

    private int code;
    private String msg;

    public Result(ResultEnum resultEnum) {
        this.code = resultEnum.getCode();
        this.msg = resultEnum.getValue();
    }

    public static Result ok(){
        return new Result(ResultEnum.SUCCESS);
    }

    public static Result ok(ResultEnum resultEnum){
        return  new Result(resultEnum);
    }

    public static Result fail(){
        return new Result(ResultEnum.FAIL);
    }
    public static Result fail(ResultEnum resultEnum){
        return new Result(resultEnum);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
